<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // let arr = [23, 45, 31, 3]
    // let iter = arr[Symbol.iterator]();//迭代器对象
    // console.log(iter);
    // console.log(iter.next().value);
    // let rel = iter.next()
    // console.log(rel.value, rel.done);
    // rel = iter.next()
    // console.log(rel.value, rel.done);
    // rel = iter.next()
    // console.log(rel.value, rel.done);
    // rel = iter.next()
    // console.log(rel.value, rel.done);

    // let rel = iter.next()
    // while (!rel.done) {
    //   console.log(rel.value, rel.done);
    //   rel = iter.next()
    // }

    // 简化迭代, 默认会调用迭代器的next方法的value和iter.next().value等同
    // for (const item of iter) {
    //   console.log(item);
    // }


    // // set 迭代
    // let set = new Set(['admin', 'user', 'lisi', 'wangwu']);
    // let set_iter = set[Symbol.iterator]()

    // for (const item of set_iter) {
    //   console.log(item);
    // }

    // map迭代
    let map = new Map();
    map.set('11', 'admin1')
    map.set('22', 'admin2')
    map.set('3', 'admin3')

    let map_iter = map[Symbol.iterator]()
    for (const [k, v] of map_iter) {
      console.log(k, v);
    }


  </script>
</body>

</html>